package org.jeecg.modules.zcgl.vo;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.zcgl.entity.Region;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 区域表 封装树结构的区域的名称的实体类
 * <p>
 * 
 *
 */
@Data
@Slf4j
public class RegionIdModel implements Serializable {

    private static final long serialVersionUID = 1L;

    // 主键ID
    private String key;

    // 主键ID
    private String value;

    // 区域名称
    private String title;
    
    List<RegionIdModel> children = new ArrayList<>();
    
    /**
     * 将RegionTreeModel的部分数据放在该对象当中
     * @param treeModel
     * @return
     */
    public RegionIdModel convert(RegionTreeModel treeModel) {
        this.key = treeModel.getId();
        this.value = treeModel.getId();
        this.title = treeModel.getRegionName();
        return this;
    }
    
    /**
     * 该方法为用户区域的实现类所使用
     * @param region
     * @return
     */
    public RegionIdModel convertByUserDepart(Region region) {
        this.key = region.getId();
        this.value = region.getId();
        this.title = region.getRegionName();
        return this;
    } 
}
